import axios from 'axios';
import query from 'query-string';

const BASE_URL = '/order/order-operate-history';


export interface OrderOperateHistoryParam {
    orderId?: string;
    operateType?: number;
    page?: number;
    size?: number;
    sort?: Array<string>;
}

export interface OrderOperateHistoryResponse {
    id?: number;
    orderId: string;
    operateType: number;
    operateNote?: string;

    createdBy?: string;
    updatedBy?: string;
    createdAt?: string;
    updatedAt?: string;
}

export interface OrderOperateHistorySaveCommand {
    id?: number;
    orderId: string;
    operateType: number;
    operateNote?: string;
}

export interface OrderOperateHistoryResponseList {
    list: OrderOperateHistoryResponse[];
    total: number;
}


// 通过OrderOperateHistoryParam参数获取分页列表
export function pageOrderOperateHistory(params: OrderOperateHistoryParam) {
    return axios.get<OrderOperateHistoryResponseList>(`${BASE_URL}/page`, {
        params, paramsSerializer: (obj) => {
            return query.stringify(obj);
        }
    })
}

// 通过id获取订单操作日志信息
export function getOrderOperateHistory(id: number) {
    return axios.get<OrderOperateHistoryResponse>(`${BASE_URL}/${id}`);
    
}

export function listOrderOperateHistory(params: OrderOperateHistoryParam) {
    return axios.get<OrderOperateHistoryResponse[]>(`${BASE_URL}/list`, {
        params, paramsSerializer: (obj) => {
            return query.stringify(obj);
        }
    });
}


// 添加订单操作日志
export function addOrderOperateHistory(params: OrderOperateHistorySaveCommand) {
    return axios.post(`${BASE_URL}`, params);
}

// 更新订单操作日志
export function updateOrderOperateHistory(params: OrderOperateHistorySaveCommand) {
    return axios.put(`${BASE_URL}`, params);
}

// 批量删除订单操作日志
export function deleteOrderOperateHistory(ids: number | Array<number>) {
    return axios.delete(`${BASE_URL}/${ids}`);
}

